;;; $Id: file.sld 246 2013-10-21 05:07:48Z alan.watson.f $

(define-library (oaxaca file)

  ;; This library exports the bindings of the (scheme file) library with
  ;; some additions.
  (export call-with-input-file
          call-with-output-file
          delete-file
          file-exists?
          open-binary-input-file
          open-binary-output-file
          open-input-file
          open-output-file
          with-input-from-file
          with-output-to-file
          make-path
          oaxaca-directory-path
          home-directory-path
          oaxaca-directory-path
          move-file
          link-file
          make-directory)

  (import (scheme base)
          (scheme file)
          (scheme process-context))

  (cond-expand (chibi (import (oaxaca file-chibi))))

  (begin

    (define (make-path . rest)
      (let loop ((path (car rest))
                 (rest (cdr rest)))
        (if (null? rest)
          path
          (loop (string-append path "/" (car rest)) (cdr rest)))))

    (define (oaxaca-directory-path)
      (get-environment-variable "OAXACADIR"))

    (define (home-directory-path)
      (or (get-environment-variable "HOME") "/home/oaxaca"))
      
    (define (dot-oaxaca-directory-path)
      (or (get-environment-variable "OAXACADIR") "/usr/local/oaxaca"))))
      
      
